<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=>, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        body{
            background-color: #F3EFE0;
        }
        .bot{
            color: #918E84;
            font-family:Arial, Helvetica, sans-serif;
            font-size: 24px;
            position: relative;
            right: 200px;
            float: right;
        }
    </style>
</head>
<body>
    <p>整数1：<input id="num1" type="text"></p>
    <p>整数2：<input id="num2" type="text"></p>
    <p>
        <input type="button" value="相加" onclick="calc(add)">
        <input type="button" value="相减" onclick="calc(sub)">
        <input type="button" value="相乘" onclick="calc(mul)">
        <input type="button" value="相除" onclick="calc(div)">

    </p>
    <p>结果：<input id="result" type="text" readonly></p>
    <script>
    function calc(func){
        var result =document.getElementById('result');
        var num1=parseInt(document.getElementById('num1').value);
        var num2=parseInt(document.getElementById('num2').value);
        if(isNaN(num1)||isNaN(num2)){
            alert('请输入数字');
            return false;
        }
        result.value=func(num1,num2);
    }
    function add(num1,num2){
        return num1+num2;
    }
    function sub(num1,num2){
        return num1-num2;
    }
    function mul(num1,num2){
        return num1*num2;
    }
    function div(num1,num2){
        if(num2==0){
            alert('除数不能为0');
            return '';
        }
        return num1/num2;
    }
    </script>
    <input type="button" value="返回" onclick="location.href = '../章节目录/第五章.html'">
    <div class="bot">
        <h3>Please appreciate((●'◡'●))......</h3>
    </div>
</body>
</html>